<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ page import="phasebookws.*" %>
<%@ page import="java.util.List"%>



<%
	//HttpSession session = request.getSession(true);
IFacade facadeBean = (IFacade )session.getAttribute("PhaseBookBean");
	
if (facadeBean == null) {
	pageContext.forward("Login.jsp");
}
else {
	Userprofile loggedProfile = facadeBean.getLoggedProfile((PhasebookToken) session.getAttribute("UID"));
	Integer loggedUserId = loggedProfile.getUserId();
	
	String userName = request.getParameter("userName");
	Userprofile viewedProfile = facadeBean.getProfileByUsername((PhasebookToken) session.getAttribute("UID"), userName);
	Integer viewedUserId = viewedProfile.getUserId();
%>
<%
		List<Usermessage> listPublicMsg = null;
		PhasebookToken tokenTemp = new PhasebookToken();
		tokenTemp.setUserId(viewedUserId); 
		tokenTemp.setToken(((PhasebookToken) session.getAttribute("UID")).getToken());
		tokenTemp.setAppId(((PhasebookToken) session.getAttribute("UID")).getAppId());
		listPublicMsg = facadeBean.getPublicMessageList(tokenTemp).getItem();

		List<Usermessage> listPrivateMsg = null;
		listPrivateMsg = facadeBean.getPrivateMessageList(tokenTemp).getItem();
		
		
		
		listPublicMsg.addAll(listPrivateMsg);
%>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script type="text/javascript">

</script>

</head>
<body>





	<table>
	<%
		for (Usermessage msg1 : listPublicMsg) {
	%>
		<tr>
			<td>
			<hr>
			<% 
				Userphoto photo = msg1.getPhotoId();
			if ((photo != null) && (!photo.getPhotoPath().trim().equals("KO"))) {
			%>
			<br/>
					<a href="./image/<%= photo.getPhotoPath() %>"><img class="wall-image" src="./image/<%= photo.getPhotoPath() %>" /></a>
			<%
				} // photo != null
			%>	
			</td>
		</tr>
	<% 
		} // for each message 
	%>
	</table>
	
</body>
</html>
<% } // else do bean != null %>

